#ifndef DRAWING_H
#define DRAWING_H

#include <QGraphicsScene>
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsItem>
#include <QWheelEvent>
#include <vector>
#include<QGraphicsView>
#include<QTransform>
class DrawingScene : public QGraphicsScene
{
    Q_OBJECT
public:
    explicit DrawingScene(QObject *parent = nullptr);
    void undo();
    void redo();
    void mouseswitch(int x);
    bool canUndo() const;
    bool canRedo() const;
    void eraseItems();


signals:
    void drawingchanged();


protected:
    void mousePressEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override;
    void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override;


private:

    bool m_isErasing;
    bool m_isDrawing;
    QPointF m_lastPos;
    QList<QGraphicsItem*> m_items;
    QList<QList<QGraphicsItem*>> m_undoStack;
    QList<QList<QGraphicsItem*>> m_redoStack;
    QList<QGraphicsItem*> m_currentOperation;
    QGraphicsView *m_view; // 添加一个成员变量，用于保存视图
    int m_eraseWidth;
    int m_mouse;
    void updateView(); // 添加一个私有函数，用于更新视图


};

#endif // DRAWING_H

